package com.yinhai.util;


public class SettingEntity {
	public static final String WEATHER_ACCEPT_MESSAGE_NOTIFICATION = "weather_accept_message_notification";
	public static final String IS_VOICE_NOTIFICATION_ON = "is_voice_notification_on";
	public static final String IS_VIBRATE_NOTIFICATION_ON = "is_vibrate_notification_on";
	public static final String WEATHER_USE_SPEAKER_PLAY_VOICE = "weather_use_speaker_play_voice";
	public static final String IS_FIRST_EXECUTE="is_first_execute";
	
	private boolean weatherAcceptMessageNotification;
	private boolean isVoiceNotificationOn;
	private boolean isVibrateNotificationOn;
	private boolean weatherUseSpeakerPlayVoice;
	private boolean isFirstExecute;
	
	private static SettingEntity entity;
	
	private SettingEntity() {
	}
	
	public static SettingEntity getInstance() {
		if(entity == null) {
			entity = new SettingEntity();
		}
		return entity;
	}
	
	public void setWeatherAcceptMessageNotification(boolean weaherOrNot) {
		this.weatherAcceptMessageNotification = weaherOrNot;
	}
	
	public boolean getWeatherAcceptMessageNotification() {
		return this.weatherAcceptMessageNotification;
	}
	
	public void setIsVoiceNotificationOn(boolean onOrOff) {
		this.isVoiceNotificationOn = onOrOff;
	}
	
	public boolean getIsVoiceNotificationOn() {
		return this.isVoiceNotificationOn;
	}
	
	public void setIsVibrateNotificationOn(boolean onOrOff) {
		this.isVibrateNotificationOn = onOrOff;
	}
	
	public boolean getIsVibrateNotificationOn() {
		return this.isVibrateNotificationOn;
	}
	
	public void setWeatherUseSpeakerPlayVoice(boolean weaherOrNot) {
		this.weatherUseSpeakerPlayVoice = weaherOrNot;
	}
	
	public boolean getWeatherUseSpeakerPlayVoice() {
		return this.weatherUseSpeakerPlayVoice;
	}
	
	public void setIsFirstExecute(boolean weaherOrNot) {
		this.isFirstExecute = weaherOrNot;
	}
	
	public boolean getIsFirstExecute() {
		return this.isFirstExecute;
	}
	
	/**
	 * 保存单个设置
	 * 
	 * @param key
	 * @param value
	 */
	public void saveSingleSettingToSharedPreference(String key, boolean value) {
		CMSharedPreferences.putSettingBoolean(key, value);
	}
	
	/**
	 * 保存设置
	 */
	public void saveSettingToSharedPreference() {
		CMSharedPreferences.putSettingBoolean(WEATHER_ACCEPT_MESSAGE_NOTIFICATION, weatherAcceptMessageNotification);
		CMSharedPreferences.putSettingBoolean(IS_VOICE_NOTIFICATION_ON, isVoiceNotificationOn);
		CMSharedPreferences.putSettingBoolean(IS_VIBRATE_NOTIFICATION_ON, isVibrateNotificationOn);
		CMSharedPreferences.putSettingBoolean(WEATHER_USE_SPEAKER_PLAY_VOICE, weatherUseSpeakerPlayVoice);
		CMSharedPreferences.putSettingBoolean(IS_FIRST_EXECUTE, isFirstExecute);
	}
	
	/**
	 * app启动后载入设置
	 */
	public void loadSettingFromSharedPreference() {
		this.weatherAcceptMessageNotification = CMSharedPreferences.getSettingBoolean(WEATHER_ACCEPT_MESSAGE_NOTIFICATION, true);
		this.isVoiceNotificationOn = CMSharedPreferences.getSettingBoolean(IS_VOICE_NOTIFICATION_ON, true);
		this.isVibrateNotificationOn = CMSharedPreferences.getSettingBoolean(IS_VIBRATE_NOTIFICATION_ON, true);
		this.weatherUseSpeakerPlayVoice = CMSharedPreferences.getSettingBoolean(WEATHER_USE_SPEAKER_PLAY_VOICE, true);
		this.isFirstExecute = CMSharedPreferences.getSettingBoolean(IS_FIRST_EXECUTE, true);
	}
}
